using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using DAL;
using BUS;
using Entities;
using Utility;

public partial class Admin_HinhThucThanhToanList : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            LoadData();
        }

    }
    private void LoadData()
    {
        Pager.PageSize = 5;
        Criteria c = new Criteria();
        if (txt_id_httt.Text != "")
        {
            c.add(Condition.AND, tbHTThanhToan .tbHTThanhToanColumns.IDHinhThuc , Condition.LIKE,
                txt_id_httt.Text);
        }
        if (txt_httt.Text != "")
        {
            c.add(Condition.AND, tbHTThanhToan.tbHTThanhToanColumns.TenHinhThuc , Condition.LIKE, txt_httt.Text);
        }
        int total = 0;
        tbHTThanhToan .tbHTThanhToanCollection  httt_Collection =
            tbHTThanhToanBus .Get(c.Criter, Pager.CurrentIndex, Pager.PageSize,
           tbHTThanhToan .tbHTThanhToanColumns .IDHinhThuc .ToString(), OrderDirection.ASC.ToString(), out total);
        Repeater1.DataSource = httt_Collection;
        Repeater1.DataBind();
        Pager.ItemCount = total;
        if (total <= Pager.PageSize)
            Pager.Visible = false;
    }
    protected void btn_Search_Click(object sender, EventArgs e)
    {
        LoadData();
    }
    protected void Pager_Command(object sender, CommandEventArgs e)
    {
        Pager.CurrentIndex = int.Parse(e.CommandArgument.ToString());
        LoadData();
    }
    protected void Repeater1_ItemDataBound(object sender, RepeaterItemEventArgs e)
    {
        if (e.Item.ItemType == ListItemType.AlternatingItem ||
            e.Item.ItemType == ListItemType.Item)
        {

            tbHTThanhToan  httt_tbl = (tbHTThanhToan )e.Item.DataItem;
            Literal lit_httt = (Literal)e.Item.FindControl("lit_httt");
            Literal lit_id_httt = (Literal)e.Item.FindControl("lit_id_httt");

            HyperLink hpl_Edit = (HyperLink)e.Item.FindControl("hpl_Edit");
            HiddenField hf_id = (HiddenField)e.Item.FindControl("hf_id");


            lit_httt.Text = httt_tbl.TenHinhThuc ;
            lit_id_httt.Text = httt_tbl.IDHinhThuc .ToString();
            hf_id.Value = httt_tbl.IDHinhThuc .ToString();

            hpl_Edit.NavigateUrl = "HinhThucThanhToanUpdate.aspx?id=" + httt_tbl.IDHinhThuc.ToString();


        }
    }
}
